//
// Created by 紫霄 on 2020/4/25.
//

#ifndef LEETCODE_57_2_H
#define LEETCODE_57_2_H
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
class Solution {
public:
  vector<vector<int>> findContinuousSequence(int target) {
    vector<vector<int>> ans;
    vector<int> curResult;
    int max = sqrt(2 * target);
    for (int n = max; 1 < n; --n) {
      int M = target - (n * n - n) / 2;
      if (M % n == 0) {
        int m = M / n;
        curResult.clear();
        for (int i = m; i < m + n; ++i) {
          curResult.emplace_back(i);
        }
        ans.emplace_back(curResult);
      }
    }
    return ans;
  }
};
#endif // LEETCODE_57_2_H
